Posts

Showing posts from April, 2024

JavaScript : Generate a random number

  let random = Math . floor ( Math . random () * arr . length )

Javascript: async await fetch Api [get and post ]

  // async function getdata() { //   return new Promise((resolve, reject) => { //     setInterval(() => { //       resolve(455); //     }, 40000); //   }); // } async function getdata () {   let x = await fetch ( "https://jsonplaceholder.typicode.com/todos/1" );   data = await x . json ();   console . log ( data );   return 455 ;   // .then((response) => response.json())   // .then((json) => console.log(json)); } async function postreqexample () {   let x = fetch ( "https://jsonplaceholder.typicode.com/posts" , {     method : "POST" ,     body : JSON . stringify ({       title : "foo" ,       body : "bar" ,       userId : 1 ,     }),     headers : {       "Content-type" : "application/json; charset=UTF-8" ,     },   })     . then (( response ) => res...

Javascript: promise

  console . log ( "promise means prose of code eecution " ); let prom1 = new Promise (( resolve , reject ) => {   setTimeout (() => {     a = 0.3 ;     if ( a < 0.9 ) {       console . log ( "not resolving promise" );       alert ( "not resolving promise" );       resolve ( "Pulkit not resolved" );     } else {       console . log ( "resolving promise" );       alert ( "resolving promise" );       resolve ( "Pulkit" );     }   }, 4000 ); }); prom1   . then (( a ) => {     console . log ( a );   })   . catch (( err ) => {     console . log ( err );   });

Javascript : call back , calling function on demand from code

  function callback ( arg ) {   console . log ( arg );   alert ( arg ); } const loadscript = ( src , callback ) => {   let sc = document . createElement ( "script" );   sc . src = src ;   sc . onload = callback ( "Pulkit" );   document . head , append ( sc ); }; loadscript (   "https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/prism.min.js" ,   callback );

Javascript : set time out, get random number between , set time interval Javascript

  <! DOCTYPE html > < html lang = "en" >   < head >     < meta charset = "UTF-8" />     < meta name = "viewport" content = "width=device-width, initial-scale=1.0" />     < title >EVENT BUBBLING</ title >     < style >       .container {         background-color: rgb ( 221 , 129 , 10 );         border: 2 px solid black ;         padding: 10 px ;         margin: auto ;         cursor: pointer ;       }       .childcontainer {         background-color: rgb ( 10 , 116 , 21 );         border: 2 px solid black ;         padding: 10 px ;         margin: auto ;         cursor: pointer ;       }       .child { ...

EA System Revolution 1.0

 //+------------------------------------------------------------------+ //|                                  EA Systems - Revolution 1.0.mq5 | //|                                  Copyright 2023, MetaQuotes Ltd. | //|                                             https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link      "https://www.mql5.com" #property version   "1.00" #include <Trade\Trade.mqh> CTrade trade; input double lotsize; input string TradeStartTime = "15:34"; input string TradeStopTime = "15:36"; input bool CloseTradesAtStopTime=false; input double Target;...

MT5 Time fileter and Time based exit

 input string TradeStartTime = "15:34"; input string TradeStopTime = "15:36";    if(TimeCurrent()>StringToTime(TradeStartTime) && TimeCurrent()<StringToTime(TradeStopTime))      {       EAActivated = true;      }    else      {       EAActivated = false;      }    if(EAActivated == true)      {       check="Trading enabled";      }    if(EAActivated == false)      {       check="Trading Disabled";      }    if(CloseTradesAtStopTime==true &&TimeCurrent()>StringToTime(TradeStopTime))      {       close_sell_position();       close_buy_position();      }

MT5 Sachin BigBoss Forex Big candle strategy

//+------------------------------------------------------------------+ //|                                             BigBossBigCandle.mq5 | //|                                  Copyright 2023, MetaQuotes Ltd. | //|                                             https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link      "https://www.mql5.com" #property version   "1.00" #include <Trade\Trade.mqh> CTrade trade; datetime ExitTime; input string TradeStartTime = "00:00"; input string TradeStopTime = "23:36"; input bool CandleClosing=false; input b...