Amibroker Code Reviser Needed

Job ID: 39526034

Budget: $20 – $30 USD

Hello,

I need someone to fix my AFL code or write a new one.

I am trying to use StopLoss/Take Profit based exits when either current bar H >= Take Profit OR L <= StopLoss and then I apply Iff function for StopLoss with a nested Iff TakeProfit, by prioritizing StopLoss, in case both targets where meet in the same bar, however, my profit/loss calculation seems by completely off.

Second issue I am running into is, if there is trade exit(since I am using OHLC data) there can be new trades opened within the same bar previous close occured, so AFL counts as a "double trade", I tried using Barssince(exit condition) > 0, but not sure, if that is the best solution.

If I use the built-in ApplyStop function, I can't control new trades on the same bar and I prefer H >= Take Profit OR L <= StopLoss, because I wan to make sure that H was actually "through" Profit level and not just touched.

Anyway, either fix my code or write a new one.

If you write a new one, here are the rules:

Buy = H >= Ref(H,-1); entry price = Ref(H,-1); Profit Target ATR(10) * 1 / Stop Loss ATR(10) * 2, and new trade can only occur starting next bar, when previous has closed.

In the attachment I provided AFL code and last 6mo Nasdaq Futures 1min OHLC data.

Thanks
Related categories: Algorithm Amibroker Formula Language