|
You have forgottten timeframeexpand! It has three expand option: expandlast,expandfirst,expandpoint.
Code not tested! There could be other bugs in your code.
- _SECTION_BEGIN ( "Product Settings" );
- SetPositionSize ( 1, spsShares );
- SetOption ( "MaxOpenPositions", 1 );
- SetOption ( "InitialEquity", 50000 );
- SetOption ( "FuturesMode", 1 );
- SetOption ( "CommissionMode", 3 );
- SetOption ( "CommissionAmount", 2.5 );
- RoundLotSize = 1;
- newName = strmid (Name (), 0, 2);
- roundNum = 1; // done by rounding
- // AUD
- if (newName == "6A")
- {
- TickSize = 0.0001;
- MarginDeposit = 1663.75;
- PS = 10000;
- PointValue = 10 * PS;
- roundNum = 10000; // rounded to the fourth decimal place
- }
- _SECTION_END ();
- _SECTION_BEGIN ("Logic");
- MA5 = int ( MA ( C, 5 ) * roundNum + 0.5 ) / roundNum; // MA5 rounded to the fourth decimal point
- MA5_P1 = Ref ( MA5, -1 ); // before a K rod MA5
- MA5_P2 = Ref ( MA5, -2 ); // before 2 K rod MA5
- Cond_MA5_P1_Buy = MA5_P1 > MA5_P2; // Buy
- Cond_MA5_P1_Short = MA5_P1 < MA5_P2; // Short
- MA20 = int ( MA ( C, 20 ) * roundNum + 0.5 ) / roundNum; // MA20 rounded to the fourth decimal point
- MA20_P1 = Ref ( MA20, -1 ); // rod before a K MA20
- MA20_P2 = Ref ( MA20, -2 ); // 2 K bar before MA20
- Cond_MA20_P1_Buy = MA20_P1 > MA20_P2; // Buy
- Cond_MA20_P1_Short = MA20_P1 < MA20_P2; // Short
- htf = 30 * 60;
- TimeFrameSet (htf); // switch to the 30 minutes of the K line graph
- MA5_30min = int (MA (C, 5) * roundNum + 0.5) / roundNum; // MA5 rounded to the fourth decimal point
- MA5_P1_30min = Ref (MA5_30min, -1); // before a K rod MA5
- MA5_P2_30min = Ref (MA5_30min, -2); // before 2 K rod MA5
- MA20_30min = int (MA (C, 20) * roundNum + 0.5) / roundNum; // MA20 rounded to the fourth decimal point
- MA20_P1_30min = Ref (MA20_30min, -1); // rod before a K MA20
- MA20_P2_30min = Ref (MA20_30min, -2); // before 2 K rod MA20
- TimeFrameRestore (); // reply to 10 K line graph
- expandoption = expandpoint;
- MA5_P1_30min = TimeFrameExpand( MA5_P1_30min, htf, expandoption );
- MA5_P2_30min = TimeFrameExpand( MA5_P2_30min, htf, expandoption );
- MA20_P1_30min = TimeFrameExpand( MA20_P1_30min, htf, expandoption );
- MA20_P2_30min = TimeFrameExpand( MA20_P2_30min, htf, expandoption );
- Cond_MA5_P1_Buy_30min = MA5_P1_30min > MA5_P2_30min; // Buy
- Cond_MA5_P1_Short_30min = MA5_P1_30min < MA5_P2_30min; // Short
- Cond_MA20_P1_Buy_30min = MA20_P1_30min > MA20_P2_30min; // Buy
- Cond_MA20_P1_Short_30min = MA20_P1_30min < MA20_P2_30min; // Short
- Buy = Cond_MA5_P1_Buy AND
- Cond_MA20_P1_Buy AND
- Cond_MA5_P1_Buy_30min AND
- Cond_MA20_P1_Buy_30min;
- Sell = Cond_MA5_P1_Short;
- Short = Cond_MA5_P1_Short AND
- Cond_MA20_P1_Short AND
- Cond_MA5_P1_Short_30min AND
- Cond_MA20_P1_Short_30min;
- Cover = Cond_MA5_P1_Buy;
- //Each added two points when @ trading price when the slide
- BuyPrice = (O + 2 * TickSize);
- SellPrice = (O - 2 * TickSize);
- ShortPrice = (O - 2 * TickSize);
- CoverPrice = (O + 2 * TickSize);
- if( Status( "action" ) == actionExplore );
- {
- Buy = ExRem (Buy, Sell);
- Sell = ExRem (Sell, Buy);
- Short = ExRem (Short, Cover);
- Cover = ExRem (Cover, Short);
- // Explore by
- Filter = Buy OR Sell OR Short OR Cover;
- // Explore with the following display
- AddColumn (Buy, "Buy", 1);
- AddColumn (Sell, "Sell", 1);
- AddColumn (Short, "Short", 1);
- AddColumn (Cover, "Cover", 1);
- AddColumn (MA5_P1, "MA5_P1", 1.4);
- AddColumn (MA5_P2, "MA5_P2", 1.4);
- AddColumn (Cond_MA5_P1_Buy, "Cond_MA5_P1_Buy", 1);
- AddColumn (Cond_MA5_P1_Short, "Cond_MA5_P1_Short", 1);
- AddColumn (MA20_P1, "MA20_P1", 1.4);
- AddColumn (MA20_P2, "MA20_P2", 1.4);
- AddColumn (Cond_MA20_P1_Buy, "Cond_MA20_P1_Buy", 1);
- AddColumn (Cond_MA20_P1_Short, "Cond_MA20_P1_Short", 1);
- AddColumn (MA5_P1_30min, "MA5_P1_30min", 1.4);
- AddColumn (MA5_P2_30min, "MA5_P2_30min", 1.4);
- AddColumn (Cond_MA5_P1_Buy_30min, "Cond_MA5_P1_Buy_30min", 1);
- AddColumn (Cond_MA5_P1_Short_30min, "Cond_MA5_P1_Short_30min", 1);
- AddColumn (MA20_P1_30min, "MA20_P1_30min", 1.4);
- AddColumn (MA20_P2_30min, "MA20_P2_30min", 1.4);
- AddColumn (Cond_MA20_P1_Buy_30min, "Cond_MA20_P1_Buy_30min", 1);
- AddColumn (Cond_MA20_P1_Short_30min, "Cond_MA20_P1_Short_30min", 1);
- }
- _SECTION_END ();
複製代碼
|
|