Profit factor:
1.84

This script is designed to automatically trade on a currency pair (like EUR/USD) using the Ichimoku Kinko Hyo, a popular technical analysis indicator. Here's how it works, broken down step-by-step:

  1. Understanding the Ichimoku Indicator: The script heavily relies on the Ichimoku indicator, which uses several lines to provide insights into potential support and resistance levels, as well as overall trend direction. Key lines in this indicator, are the "Tenkan-sen", "Kijun-sen", "Senkou Span A", and "Senkou Span B". These are calculated based on price data over different periods.

  2. Fetching Indicator Values: The script starts by pulling the current values of these Ichimoku lines from the market. These values represent the calculated price levels derived from the Ichimoku indicator. Specifically, it gets the values for the current and previous bars (or periods) on the chart. It is important to understand that this script uses predefined time periods (9,26,52) wich are default values and influence the line calculations.

  3. Managing Orders: The script checks the existing orders. It only performs actions (opening or closing positions) if certain criteria are met.

  4. Opening a "Buy" (Long) Position:

    • The script first verifies that there are no open orders.
    • It checks for a specific pattern of Ichimoku lines. It checks to see if the Tenkan-sen line was below the Kijun-sen line in the previous period but is now above the Kijun-sen line. This is considered a bullish signal.
    • If the "Senkou Span A" is above the "Senkou Span B," it means the cloud is bullish and indicates a potential upward trend.
    • If these conditions are met, it checks the current market price ("Ask" for buying) in relation to the Senkou Spans:
      • If the price is above the Senkou Span A line, it places a "Buy" order.
      • If the price is between the Senkou Span A and Senkou Span B lines, it places a "Buy" order.
      • If Senkou Span B is above Senkou Span A, it checks the current market price ("Ask" for buying) in relation to the Senkou Spans:
      • If the price is between the Senkou Span A and Senkou Span B lines, it places a "Buy" order.
      • If the price is below both Senkou Spans, it places a "Buy" order with a fixed stop loss.
  5. Closing a "Buy" (Long) Position:

    • If a "Buy" order is already open, the script checks if the Ichimoku lines are showing a bearish signal.
    • It checks if the Tenkan-sen line was above the Kijun-sen line in the previous period but is now below the Kijun-sen line. This is considered a bearish signal, and the script will close the open "Buy" position.
  6. Opening a "Sell" (Short) Position: This logic mirrors the "Buy" conditions but looks for the opposite patterns in the Ichimoku lines.

    • The script first verifies that there are no open orders.
    • It checks to see if the Tenkan-sen line was above the Kijun-sen line in the previous period but is now below the Kijun-sen line. This is considered a bearish signal.
    • If the "Senkou Span A" is below the "Senkou Span B," it means the cloud is bearish and indicates a potential downward trend.
    • If these conditions are met, it checks the current market price ("Bid" for selling) in relation to the Senkou Spans:
      • If the price is below the Senkou Span A line, it places a "Sell" order.
      • If the price is between the Senkou Span A and Senkou Span B lines, it places a "Sell" order.
      • If Senkou Span B is below Senkou Span A, it checks the current market price ("Bid" for selling) in relation to the Senkou Spans:
      • If the price is between the Senkou Span A and Senkou Span B lines, it places a "Sell" order.
      • If the price is above both Senkou Spans, it places a "Sell" order with a fixed stop loss.
  7. Closing a "Sell" (Short) Position:

    • If a "Sell" order is already open, the script checks if the Ichimoku lines are showing a bullish signal.
    • It checks if the Tenkan-sen line was below the Kijun-sen line in the previous period but is now above the Kijun-sen line. This is considered a bullish signal, and the script will close the open "Sell" position.

In Summary: This script automates trading based on the Ichimoku Kinko Hyo indicator. It looks for specific alignment of the Ichimoku lines to determine when to open and close "Buy" and "Sell" positions, attempting to capitalize on potential price trends.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Ichimoku Kinko Hyo
9 Views
0 Downloads
0 Favorites
email
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

int start()
{
// double tenkan, kijun, tenkan2, kijun2; //you don't need these...
// double senkouspanA, senkouspanB;       //you don't need these...


double tenkan=iIchimoku(Symbol(),0,9,26,52,MODE_TENKANSEN,1);
double kijun=iIchimoku(Symbol(),0,9,26,52,MODE_KIJUNSEN,1);
double tenkan2=iIchimoku(Symbol(),0,9,26,52,MODE_TENKANSEN,2);
double kijun2=iIchimoku(Symbol(),0,9,26,52,MODE_KIJUNSEN,2);
double senkouspanA=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANA,1);
double senkouspanB=iIchimoku(Symbol(),0,9,26,52,MODE_SENKOUSPANB,1);

// conditions for opening long position

if (OrdersTotal()==0)
{
if (tenkan2<kijun2)
{
if (tenkan>kijun)
{
if (senkouspanA>senkouspanB)
{
if (Ask>senkouspanA)
{
OrderSend(Symbol(),OP_BUY,6,Ask,0,(senkouspanB-10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanA>Ask>senkouspanB)
{
OrderSend(Symbol(),OP_BUY,3,Ask,0,(senkouspanB-10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanB>senkouspanA)
{
OrderSend(Symbol(),OP_BUY,6,Ask,0,(senkouspanA-10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanB>Ask>senkouspanA)
{
OrderSend(Symbol(),OP_BUY,3,Ask,0,(senkouspanA-10*Point),0,0,0,0,1);
return(0);
{
if (Ask<senkouspanA)
{
if (Ask<senkouspanB)
{
OrderSend(Symbol(),OP_BUY,1,Ask,0,(Bid-100*Point),0,0,0,0,1);
return(0);
}}}}}}}}}}}}}}

// condition for closing long position

if (OrdersTotal()==1)
{
if (OrderType()==OP_BUY)
{
if (tenkan2>kijun2) 
{
if (tenkan<kijun)
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,1);
return(0);
}}}}

// conditions for opening up short position

if (OrdersTotal()==0)
{
if (tenkan2>kijun2)
{
if (tenkan<kijun)
{
if (senkouspanA<senkouspanB)
{
if (Bid<senkouspanA)
{
OrderSend(Symbol(),OP_SELL,6,Bid,0,(senkouspanB+10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanB>Bid>senkouspanA)
{
OrderSend(Symbol(),OP_SELL,3,Bid,0,(senkouspanB+10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanB<senkouspanA)
{
if (Bid<senkouspanB)
{
OrderSend(Symbol(),OP_SELL,6,Bid,0,(senkouspanA+10*Point),0,0,0,0,1);
return(0);
{
if (senkouspanA>Bid>senkouspanB)
{
OrderSend(Symbol(),OP_SELL,3,Bid,0,(senkouspanA+10*Point),0,0,0,0,1);
return(0);
{
if (Bid>senkouspanA)
{
if (Bid>senkouspanB)
{
OrderSend(Symbol(),OP_SELL,1,Bid,0,(Ask+100*Point),0,0,0,0,1);
return(0);
}}}}}}}}}}}}}}}

// condition for closing short position

if (OrdersTotal()==1)
{
if (OrderType()==OP_SELL)
{
if (tenkan2<kijun2) 
{
if (tenkan>kijun)
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,1);
return(0);
}}}}
}

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 12069.57
Gross Profit 12069.57
Gross Loss 0.00
Total Net Profit 12069.57
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.00
Total Trades 4
Won Trades 0
Lost trades 4
Win Rate 0.00 %
Expected payoff -1750.26
Gross Profit 0.00
Gross Loss -7001.05
Total Net Profit -7001.05
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -2334.20
Gross Profit 0.00
Gross Loss -7002.61
Total Net Profit -7002.61
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 10236.00
Gross Profit 10236.00
Gross Loss 0.00
Total Net Profit 10236.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -2583.49
Gross Profit 0.00
Gross Loss -7750.48
Total Net Profit -7750.48
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 4
Won Trades 0
Lost trades 4
Win Rate 0.00 %
Expected payoff -1938.00
Gross Profit 0.00
Gross Loss -7752.00
Total Net Profit -7752.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -1906.80
Gross Profit 0.00
Gross Loss -9534.00
Total Net Profit -9534.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
23.57
Total Trades 2
Won Trades 1
Lost trades 1
Win Rate 50.00 %
Expected payoff 26593.62
Gross Profit 55543.29
Gross Loss -2356.06
Total Net Profit 53187.23
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.00
Total Trades 2
Won Trades 0
Lost trades 2
Win Rate 0.00 %
Expected payoff -3500.74
Gross Profit 0.00
Gross Loss -7001.49
Total Net Profit -7001.49
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -1700.03
Gross Profit 0.00
Gross Loss -8500.16
Total Net Profit -8500.16
-100%
-50%
0%
50%
100%

Comments