I am developing a strategy for RENKOBARS 10/5 in which the entry is made when the price breaks the Swing indicator, buying above and selling below. The Stop is set with a limit order which trails as the indicator moves (TRAILING MODE). Additionally, a Fibonacci retracement is drawn in the space between the upper and lower Swing(see image). Finally, the Profit has been calculated at Fibonacci levels of 25% and 61.8% (2 contracts) OR 61.8% and 100% (defined by user).
Also I have created a STATIC MODE so when true, the stop loss and profits are fixed so that even though the swing indicator upsates, they remain fixed at the entry point swing.
I tried to do this with a bolean called StopLossSet = False and set to true when the entry has been made. I didnt set up the Profits to be static because I couldnt make the stop to work... see in the image how the stop and profits are being recalculated as the new swings come up...
How can I do this? How can I block the values updating? Please take be aware that I ONLY want this when the STATIC MODE is True, if it's False then it will update the Stop with the new swings that come up (TRAILING MODE).
I attach the complete strategy without the bolean.
Here the code I made with the bolean:
// Set 15 / LONG ===> SWING if ((Close[0] > Open[0]) && (Close[1] > Open[1]) && (Close[2] > Open[2]) && (Swing1.SwingHigh[2] > Close[2]) && (Swing1.SwingHigh[1] < Close[1]) && (Close[0] > Swing1.SwingHigh[2]) && (Buy_activar == true) && (Times[0][0].TimeOfDay >= Hora_inicio.TimeOfDay) && (Times[0][0].TimeOfDay <= Hora_cierre.TimeOfDay) && (Trade_1 == true) && (Trade_2 == true) && (Filtro_momentum == false) && (Cruce_EMAS == false) && (Entrada_PSAR == false) && (Entrada_Swing == true) && (stopLossSet == false) ) { EnterLong(Ncontratos_trade1, @"EntryLong1"); EnterLong(Ncontratos_trade2, @"EntryLong2"); Draw.FibonacciRetracements(this, @"BuscandoLaVelaR3 Fibonacci retracements_1", true, 0, Swing1.SwingLow[0], 0, Swing1.SwingHigh[0]); LimiSupFB = (Swing1.SwingHigh[0]); LimInfFB = (Swing1.SwingLow[0]); RangoFB = LimiSupFB-LimInfFB; PS162b = Instrument.MasterInstrument.RoundToTickSize(LimiSupFB + (RangoFB*Porcentaje_fibo_TP1/100)); PS200b = Instrument.MasterInstrument.RoundToTickSize(LimiSupFB + (RangoFB*Porcentaje_fibo_TP2/100)); stopLossSet == true } // Set 16 / SHORT ===> SWING if ((Close[0] < Open[0]) && (Close[1] < Open[1]) && (Close[2] < Open[2]) && (Swing1.SwingLow[2] < Close[2]) && (Swing1.SwingLow[1] > Close[1]) && (Close[0] < Swing1.SwingLow[2]) && (Sell_activar == true) && (Times[0][0].TimeOfDay >= Hora_inicio.TimeOfDay) && (Times[0][0].TimeOfDay <= Hora_cierre.TimeOfDay) && (Trade_1 == true) && (Trade_2 == true) && (Filtro_momentum == false) && (Cruce_EMAS == false) && (Entrada_PSAR == false) && (Entrada_Swing == true) && (stopLossSet == false) ) { EnterShort(Ncontratos_trade1, @"EntryShort1"); EnterShort(Ncontratos_trade2, @"EntryShort2"); Draw.FibonacciRetracements(this, @"BuscandoLaVelaR3 Fibonacci retracements_1", true, 0, Swing1.SwingLow[0], 0, Swing1.SwingHigh[0]); LimiSupFB = (Swing1.SwingHigh[0]); LimInfFB = (Swing1.SwingLow[0]); RangoFB = LimiSupFB-LimInfFB; PS162s = Instrument.MasterInstrument.RoundToTickSize(LimInfFB - (RangoFB*Porcentaje_fibo_TP1/100)); PS200s = Instrument.MasterInstrument.RoundToTickSize(LimInfFB - (RangoFB*Porcentaje_fibo_TP2/100)); stopLossSet == true } // Set 39 - 2 LONG - SWING - STATIC MODE if ( (SL_Swing == true) && (SL_Psar == false) && (SL_TssuperTrend == false) && (Position.MarketPosition == MarketPosition.Long) && (Trade_1 == true) && (Trade_2 == true) && (Modo_estatico == true) && (Modo_trailing == false) && (stopLossSet == true) ) { ExitLongStopMarket(Convert.ToInt32(Ncontratos_trade1), LimInfFB, @"StopLong1", @"EntryLong1"); ExitLongStopMarket(Convert.ToInt32(Ncontratos_trade2), LimInfFB, @"StopLong2", @"EntryLong2"); } // Set 40 - 2 SHORT - SWING - STATIC MODE if ( (SL_Swing == true) && (SL_Psar == false) && (SL_TssuperTrend == false) && (Position.MarketPosition == MarketPosition.Short) && (Trade_1 == true) && (Trade_2 == true) && (Modo_estatico == true) && (Modo_trailing == false) && (stopLossSet == true) ) { ExitShortStopMarket(Convert.ToInt32(Ncontratos_trade1), LimiSupFB, @"StopShort1", @"EntryShort1"); ExitShortStopMarket(Convert.ToInt32(Ncontratos_trade2), LimiSupFB, @"StopLong2", @"EntryLong2"); } }
Comment