Topic: bit help needed with understanding the code

hi guys
long time no see smile

i was wandering if someone could give me an explanation or at least point me in the right direction regarding some code. Recently i was looking at one of the posts regarding a dynamic SL and thought that i should be able to help.  i looked at the existing indicators related to SL and Trailing SL,  but the code looks identical when it comes to the indicator logic!  I don’t understand how the program knows to use one set of rules for one and not the other?


Re: bit help needed with understanding the code


That stuff is tricky! I had a plan modifing it some time ago, but took the easier route. How SL works, you can read here -> … culator.cs starting at line 1420 I think. Krog suggested that the BacktesterCalculator needs to be modified, and maybe the built-in SL indi too.

Good luck!

Re: bit help needed with understanding the code

Thanks  Footon
i will check it out,  as you know i am still learning smile

since i am on the subject of learning, i came across a money management strategy that i would like to program in.
mainly the idea is this, u determine the entry and the SL point for the trade, instead of B/S one contract you do 3 = 1/3 each of the value you want.  initially u set them all to same SL.  one of the contracts you set to TP at 50% of (ENTRY-SL)  (if market is volatile at your entry point this should be executed b4 the SL just because it is closer. ) contract #2 should have its TP = to 100% difference.  at the contract #1 TP fill, the remaining two contracts SL should be reduced by 50%.  this will lower your exposure by about 85%. Often, even if in long run you are wrong, the contract two TP gets triggered giving you a risk free trade with the last,  third contract and a locked profit.
do you think that the FSB  FST can handle that ?

Re: bit help needed with understanding the code

I'm not sure. I don't know how to make it work, SL gets set only once, therefore can there be SL modification? Developer knows best!

If I understand you correctly, you open 3 trades simultaneously (or lot size dividable by 3), if the first target is hit, shed 1/3 of the position and set another target for remaining positions, correct? If so, proper entry and closing indis can do the trick. But it is hard to orchestrate two indis in perfect harmony. I would use the reduce-function in strat properties, if entry indi finds upon price that the first target is hit, it sends out opposite signal, reduction at determined place takes place etc. So entry indi must mirror the closing indi and vice versa.