Good Morning, Afternoon, Evening friends. I am new to AFL. Working on Exploration for simple condition. Buy at 920 AM and Sell at 310 PM Intraday.
Written below code but not able to get result. It is coming blank row? Any suggestion. Do I need to use timeframe?
// Define the trading time for Buy and Sell
BuyTime = TimeNum() == 092000; // Buy at 9:20 AM
SellTime = TimeNum() == 152000; // Sell at 3:20 PM
// Define the Buy and Sell Conditions
Buy = BuyTime;
Sell = SellTime;
// Buy with 2 lots
PositionSize = 2 * 100; // Assuming each lot is 100 shares
// Define the Stop Loss
BuyPrice = ValueWhen(Buy, Close); // Entry price at Buy signal
StopLoss = BuyPrice - 4; // Stop loss 4 points below BuyPrice
// Exit if price hits stop loss before 3:20 PM
Sell = IIf(Close <= StopLoss, 1, Sell);
// Capture Sell Price at the time of Sell
SellPrice = ValueWhen(Sell, Close);
// Calculate Profit/Loss per share
PL = IIf(Sell, (SellPrice - BuyPrice) * PositionSize / 100, 0); // Adjusted for 2 lots
// Exploration columns for the report
Filter = Buy OR Sell; // Only show rows where buy or sell occurs
AddColumn(BuyPrice, "Buy Price", 1.2);
AddColumn(SellPrice, "Sell Price", 1.2);
AddColumn(PL, "Profit/Loss", 1.2);