I would like assistance with placing the logic correctly for order opening.... What is the best practice to open an order if the price hits a line? (additionally, with Slippage)
=============================
Factors for Order Opening:
Inserted Code int I; // Bar index int Counted_bars; // Number of counted bars Counted_bars=IndiorCounted(); // Number of counted pubs I=Bars-Counted_bars-1; // Index of the initial uncounted while(igt;=0) // Loop for uncounted pubs double MA_Line=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 0, 0,I); double S_Line1=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 2, 0, 1,I); double S_Line2=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 2, 0, 2,I); double S_Line3=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 2, 0, 3,I); double S_Line4=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 2, 0, 4,I); double U_StopLoss=iCustom(NULL,timeframe,MA StdDev,MA_Period, 1, 6, 2, 0, 5,I); double L_StopLoss=iCustom(NULL,timeframe,MA-StdDev,MA_Period, 1, 6, 2, 0, 5,I); double B_Line1=iCustom(NULL,timeframe,MA-StdDev,MA_Period, 1, 6, 0, 1,I); double B_Line2=iCustom(NULL,timeframe,MA-StdDev,MA_Period, 1, 6, 0, 2,I); double B_Line3=iCustom(NULL,timeframe,MA-StdDev,MA_Period, 1, 6, 2, 0, 3,I); double B_Line4=iCustom(NULL,timeframe,MA-StdDev,MA_Period, 1, 6, 2, 0, 4,I); double StochBuyLine = iStochastic(Symbol(),0,14,3,3,1,1,0,I); double StochSellLine = iStochastic(Symbol(),0,14,3,3,1,1,1,I); I--;
Logic needing inspection and advice:
Inserted Code if (Tradeable) else break; should CurrentPrice lt; MA_Line if StochBuyLinegt;StochSellLine StochBuyLinelt;=10 CurrentPrice = B_Line4 OpenBuyOrder @ Line4LotSize Else if StochBuyLinegt;StochSellLine StochBuyLinelt;=10 CurrentPrice = B_Line3 OpenBuyOrder @ Line3LotSize Else if StochBuyLinegt;StochSellLine StochBuyLinelt;=10 CurrentPrice = B_Line2 OpenBuyOrder @ Line2LotSize Else if StochBuyLinegt;StochSellLine StochBuyLinelt;=10 CurrentPrice = B_Line1 OpenBuyOrder @ Line1LotSize Else if StochSellLinegt;StochBuyLine StochSellLinegt;=90 CurrentPrice = B_Line4 OpenBuyOrder @ Line4LotSize Else if StochSellLine StochSellLinegt;=90 CurrentPrice = B_Line3 OpenBuyOrder @ Line3LotSize Else if StochSellLinegt;StochBuyLine StochSellLinegt;=90 CurrentPrice = B_Line2 OpenBuyOrder @ Line2LotSize Else if StochSellLinegt;StochBuyLine StochSellLinegt;=90 CurrentPrice = B_Line1 OpenBuyOrder @ Line1LotSize #91;ribbon=quot#93;#91;/font#93;