I want the averaging (n) entry interval to be based on the ATR value!
Hello. This is a little bit of fx.
Well, as the title says,EA Createbased on the source code output by, I tried to create a logic for averaging down (nampin) entry intervals using the ATR value.
I think it will be useful when you want to adjust the nampin interval to match the profit margin!
Now, here it is in a quick form.
EA Createsearch for the nampin section from the source you made.
if(isNanpin == true) NanpinLogic(NanpinCount, NanpinCustom, NanpinLots, NanpinInterval, NanpinMult, NanpinTP, NanpinSL, NanpinAdd, NanpinMax, magic_array);
Before the above processing, get the ATR value and set it to the nampin period.
// It’s a rough rule of thumb to cover about 5 days worth of profit margins. double atr_val = iATR(Symbol(), PERIOD_D1, 5, 1); // The value obtained with iATR is in chart currency, so convert it to pips. double atr_pips = PriceToPips(atr_val); // NanpinInterval is now used as a percentage specification (If NanpinInterval is set to 50, 50% of ATR becomes the nampin interval) double nanpin_interval = atr_pips * (NanpinInterval / 100);
The Nanpin function argument “NanpinInterval” becomes “nanpin_interval”
if(isNanpin == true) NanpinLogic(NanpinCount, NanpinCustom, NanpinLots, nanpin_interval, NanpinMult, NanpinTP, NanpinSL, NanpinAdd, NanpinMax, magic_array);
That’s all.
Easy, isn’t it.
The file download is below.
× ![]()