puppies pen

If you don't know where to start, start here! Don't be afraid to ask questions.

Moderator: moderators

User avatar
kiwiarian
rank: 500+ posts
rank: 500+ posts
Posts: 771
Joined: Thu Dec 23, 2021 8:15 am
Reputation: 455
Location: New Zealand
Gender: Male

Re: puppies pen

Postby kiwiarian » Thu Jun 06, 2024 7:15 pm

These are the rules I wrote last night for myself
FOCUS ON THE PROCESS, not the outcome
would the boss like this trade
Need to think about sticking to rules will give better life experiences, process matters, being impulsive wont.
consistent size is really important. Your losses will be easier to take as well.
respect /trust MA crossover for holding and close out
consider the next time frame or 2 above to help with being less impulsiveness.
---------------------------
We need to forget about passing or meeting money targets.
Are we trading according to our rules, that is the outcome we want.
PROCESS.
Maybe change our mindset a bit to we want to keep the account alive. We have the account when we paid for it, we own it, we have already got it. lets trade to our own targets now of keeping it alive, not their money pressure target. Money will come later. We will get paid at xmas time if we can keep this account alive.

position size on what you want to lose* from Michael Martin

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
kiwiarian
rank: 500+ posts
rank: 500+ posts
Posts: 771
Joined: Thu Dec 23, 2021 8:15 am
Reputation: 455
Location: New Zealand
Gender: Male

Re: puppies pen

Postby kiwiarian » Sun Nov 17, 2024 8:09 am

MQ5 inside bar with horizontal line using chatgpt
//+------------------------------------------------------------------+
//| Inside Bar Indicator.mq5 |
//| Custom Indicator for MT5 |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property version "1.04"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1

#property indicator_label1 "Inside Bar"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1

//--- input parameters
input int ArrowCode = 241; // Up Arrow code
input bool EnableAlerts = true; // Enable alerts when an inside bar is detected
input int LineExtendBars = 4; // Number of bars to extend the lines
input color LineColor = clrRed; // Color of the lines
input ENUM_LINE_STYLE LineStyle = STYLE_DASH; // Style of the lines
input int LineWidth = 1; // Width of the lines

//--- indicator buffers
double BufferInsideBar[];

//--- global variables
datetime lastAlertTime = 0; // Keeps track of the last alert time

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0, BufferInsideBar, INDICATOR_DATA);
PlotIndexSetInteger(0, PLOT_ARROW, ArrowCode);
ArraySetAsSeries(BufferInsideBar, true);

//--- indicator settings
IndicatorSetString(INDICATOR_SHORTNAME, "Inside Bar Indicator");
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);

return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//--- check for sufficient data
if (rates_total < 5) // Need at least 5 bars to extend lines 4 bars ahead
return 0;

//--- set arrays as series
ArraySetAsSeries(time, true);
ArraySetAsSeries(open, true);
ArraySetAsSeries(high, true);
ArraySetAsSeries(low, true);
ArraySetAsSeries(close, true);

//--- variables
int start;

if (prev_calculated == 0)
{
// First calculation, process all historical data
start = rates_total - 2;
ArrayInitialize(BufferInsideBar, EMPTY_VALUE);
}
else
{
// Only process new bars
start = rates_total - prev_calculated;
if (start < 2)
start = 2;
}

//--- dynamic offset for arrow placement
double offset = 2 * _Point;

//--- main loop
for (int i = start; i >= 1 && !IsStopped(); i--)
{
//--- check if bar i is an Inside Bar compared to bar i+1
if ((high[i] < high[i + 1]) && (low[i] > low[i + 1]))
{
//--- place marker above the Inside Bar (bar i)
BufferInsideBar[i] = high[i] + offset;

//--- alert if enabled and if it's the last closed candle
if (EnableAlerts && i == 1 && time[i] != lastAlertTime)
{
lastAlertTime = time[i];
string alertMessage = "Inside Bar detected on " + Symbol() + " " + TimeFrameToString(Period()) + " at " + TimeToString(time[i], TIME_DATE | TIME_MINUTES);
Alert(alertMessage);
}

//--- Calculate the average bar time (time difference between bars)
int barTime = (int)(time[i + 1] - time[i]);
if (barTime <= 0)
barTime = PeriodSeconds(); // Use chart period if calculation fails

//--- Calculate line end time
datetime lineEndTime = time[i] + (barTime * LineExtendBars);

//--- Create unique object names using time
string highLineName = "InsideBarHigh_" + IntegerToString(time[i]);
string lowLineName = "InsideBarLow_" + IntegerToString(time[i]);

//--- Delete existing lines if any
ObjectDelete(0, highLineName);
ObjectDelete(0, lowLineName);

//--- Create trend lines at high and low
ObjectCreate(0, highLineName, OBJ_TREND, 0, 0, 0);
ObjectCreate(0, lowLineName, OBJ_TREND, 0, 0, 0);

//--- Set coordinates for the high line
ObjectSetInteger(0, highLineName, OBJPROP_TIME, 0, time[i]);
ObjectSetDouble(0, highLineName, OBJPROP_PRICE, 0, high[i]);
ObjectSetInteger(0, highLineName, OBJPROP_TIME, 1, lineEndTime);
ObjectSetDouble(0, highLineName, OBJPROP_PRICE, 1, high[i]);

//--- Set coordinates for the low line
ObjectSetInteger(0, lowLineName, OBJPROP_TIME, 0, time[i]);
ObjectSetDouble(0, lowLineName, OBJPROP_PRICE, 0, low[i]);
ObjectSetInteger(0, lowLineName, OBJPROP_TIME, 1, lineEndTime);
ObjectSetDouble(0, lowLineName, OBJPROP_PRICE, 1, low[i]);

//--- Set line properties
ObjectSetInteger(0, highLineName, OBJPROP_COLOR, LineColor);
ObjectSetInteger(0, highLineName, OBJPROP_STYLE, LineStyle);
ObjectSetInteger(0, highLineName, OBJPROP_WIDTH, LineWidth);

ObjectSetInteger(0, lowLineName, OBJPROP_COLOR, LineColor);
ObjectSetInteger(0, lowLineName, OBJPROP_STYLE, LineStyle);
ObjectSetInteger(0, lowLineName, OBJPROP_WIDTH, LineWidth);

//--- Prevent lines from being selectable/movable
ObjectSetInteger(0, highLineName, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, highLineName, OBJPROP_HIDDEN, true);

ObjectSetInteger(0, lowLineName, OBJPROP_SELECTABLE, false);
ObjectSetInteger(0, lowLineName, OBJPROP_HIDDEN, true);
}
else
{
BufferInsideBar[i] = EMPTY_VALUE;

//--- Delete any existing lines for this bar
string highLineName = "InsideBarHigh_" + IntegerToString(time[i]);
string lowLineName = "InsideBarLow_" + IntegerToString(time[i]);

ObjectDelete(0, highLineName);
ObjectDelete(0, lowLineName);
}
}

return(rates_total);
}

//+------------------------------------------------------------------+
//| Helper function to convert Period() to a readable string |
//+------------------------------------------------------------------+
string TimeFrameToString(int period)
{
switch (period)
{
case PERIOD_M1: return "M1";
case PERIOD_M5: return "M5";
case PERIOD_M15: return "M15";
case PERIOD_M30: return "M30";
case PERIOD_H1: return "H1";
case PERIOD_H4: return "H4";
case PERIOD_D1: return "D1";
case PERIOD_W1: return "W1";
case PERIOD_MN1: return "MN1";
default: return "Time Frame";
}
}
//+------------------------------------------------------------------+

User avatar
TheRumpledOne
rank: 10000+ posts
rank: 10000+ posts
Posts: 15651
Joined: Sun May 14, 2006 9:31 pm
Reputation: 3038
Location: Oregon
Real name: Avery T. Horton, Jr.
Gender: None specified
Contact:

Re: puppies pen

Postby TheRumpledOne » Mon Nov 18, 2024 2:28 pm

kiwiarian wrote:MQ5 inside bar with horizontal line using chatgpt


What prompt did you give ChatGPT?
IT'S NOT WHAT YOU TRADE, IT'S HOW YOU TRADE IT!

Please do NOT PM me with trading or coding questions, post them in a thread.

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “beginners forum”