Profit factor:
11.36

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
2 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/CAD Oct 2024 - Jan 2025
11.36
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff 5356.56
Gross Profit 17620.77
Gross Loss -1551.08
Total Net Profit 16069.69
-100%
-50%
0%
50%
100%

Comments