I started using these Amibroker examples as a basis for implementing the following idea.
I entered the negotiation (BUY) the value of the purchase is 11 and the ATR 0.50.
My condition for the scale in occurrence is as follows: If the asset price rises 0.5 Atr, the scale in fires. This is if the price reaches 11, 25, recalculate the established PS and I add contracts in my negotiation. For me to analyze if it happens scale in again I now use the price of 11.25 as a basis to identify the new occurrence of the condition. Or Be it, if the price is for 11.50 = 11.25 + 0.25, scale in again, I will introduce contracts in my trading.
But I have a problem that I need to store the purchase value of the first ScaleIn to determine if the next one will occur or not. and so on. Since this is only taking the price of when the purchase occurred (BUY).
Follow the idea I used and I realize this problem, you have any suggestions that I can use!
PositionRisk = 0.01; pct = (MarginDepositPositionRisk100 / (PointValue * ATR(20))); AtrI = ValueWhen( Buy, ATR(20)); DoScaleIn = C > (ValueWhen(Buy, C) + 0.5*AtrI);// This value here needs to be fulfilled in every scale in which I take as my basis of decision, whether there will be another entry in the negotiation or not. Buy = Buy + SigScaleIn * DoScaleIn; SetPositionSize( pct, spsPercentOfEquity ); SetPositionSize( 10, spsShares * ( Buy == sigScaleIn ));